define(['jquery', 'bootstrap', 'backend', 'form', 'fastflow-base'], function ($, undefined, Backend, Form, FastflowBase) {

    var Controller = {
        index: function () {
            Form.api.bindevent($("form[role=form]"));
            Controller.api.bindBillShowWayEvent();
        },
        api: {
            bindevent: function () {

            },
            bindBillShowWayEvent: function () {
                $('input:radio[name="row[billshowway]"]').on('click', function () {
                    let val = $('input:radio[name="row[billshowway]"]:checked').val();
                    var index = layer.load();
                    $.ajax({
                        type: "POST",
                        url: "fastflow/flow/config/handleBillShowWayAjax",
                        data: {billshowway: val},
                        dataType: "json",
                        success: function (data) {
                            if (data['code'] == 1) {
                                Toastr.success(data['msg']);
                                top.window.$(".sidebar-menu").trigger("refresh");
                                setTimeout(function (e){
                                    FastflowBase.api.renderbadge();
                                }, 1000 );
                            }else if (data['code'] == 0) {
                                Toastr.error(data['msg']);
                            }
                            layer.close(index);
                        },
                        error: function (e) {
                            layer.close(index);
                        }
                    });
                });
            }
        }
    };
    return Controller;
});